package equalstostring.exer;

/**
 * @author shkstart
 * @date 2022/5/14 - 17:39
 */
public class Circle extends GeometricObject {
    private double radius;

    public Circle(){
        super();
        radius = 1.0;
    }

    public Circle(double radius) {
        super();
        this.radius = radius;
    }

    public Circle(double radius,String color,double weight) {
        super(color,weight);
        this.radius = radius;
    }


    public double getRadius() {
        return radius;
    }

    public void setRadius(double radius) {
        this.radius = radius;
    }


    public double findArea() {
        return Math.PI * getRadius() * getRadius();
    }

    public boolean equals(Object obj) {
        if (this == obj) { //重写编写equals方法
            return true;
        }

        if (obj instanceof Circle) {
            Circle circle = (Circle)obj;
            return this.findArea() == circle.findArea();
        }else {
            return false;
        }
    }

    public String toString() {
//        return "findArea is " + this.findArea(); //这里的+是String类型的连接
         return "Circle [radius =" +  this.getRadius() + " ]";   //标准写法                             // 只要前面是String类型后边 可以 + 任何类型(不确定)。
    }
}
